﻿namespace SingleBlog
{
    using Microsoft.EntityFrameworkCore;
    using Microsoft.EntityFrameworkCore.Infrastructure;
    using Microsoft.EntityFrameworkCore.Storage;

    /// <summary>
    /// 表示扩展。
    /// </summary>
    public static class Extensions
    {
        /// <summary>
        /// 表示当前数据库是否存在。
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public static bool DatabaseExist(this DbContext context)
        =>
            (context.Database.GetService<IDatabaseCreator>() as IRelationalDatabaseCreator).Exists();
        
    }
}
